<span id="foobar_<{$widgets_id}>" style="position: relative;">
 <{t app="b2c"}>您好<{/t}><span id="uname_<{$widgets_id}>"></span>!&nbsp;
  <span id="loginBar_<{$widgets_id}>" style="" class="loginBar ie-bug">
    <{foreach from=$data.login_content item=login}>
    <{$login}>
    <{/foreach}>
        <a href="<{link app=b2c ctl=site_passport act=login}>"><{t app="b2c"}>[请登录]<{/t}></a>&nbsp;&nbsp;
         <{if $data.open_id_open == 'true'}>
          [<a  class="trustlogin trust__login" href="javascript:void(0)"><{t}>信任登录<{/t}></a>]&nbsp;&nbsp;
          <div id="accountlogin" ><h5 class="textleft">您还可以使用以下帐号登录：</h5>
          <div class="logoimg">
            <span><img src="<{$data.res_url}>/accountlogos/trustlogo1_small.gif" /></span>
            <span><img src="<{$data.res_url}>/accountlogos/trustlogo2_small.gif" /></span>
            <span><img src="<{$data.res_url}>/accountlogos/trustlogo3_small.gif" /></span>
            <span><img src="<{$data.res_url}>/accountlogos/trustlogo4_small.gif" /></span>
          </div>
          </div>
          <{/if}>
        <a href="<{link app=b2c ctl=site_passport act=signup}>"><{t app="b2c"}>[免费注册]<{/t}></a>
  </span>
  <span id="memberBar_<{$widgets_id}>" style="display:none" class="memberBar">
    <a href="<{link app=b2c ctl=site_member}>"><{t app="b2c"}>[会员中心]<{/t}></a>&nbsp;&nbsp;
    <a href="<{link app=b2c ctl=site_passport act=logout}>"><{t app="b2c"}>[退出]<{/t}></a>
  </span>
  <{if $setting.show_cur}>
  &nbsp;
  <span id="Cur_sel_<{$widgets_id}>" style="cursor: default;">
  <strong></strong>
  <{img src="bundle/arrow-down.gif" app="b2c"}>

  </span>

  <{/if}>
  <{if $setting.show_cart}>
  &nbsp;
  <a href="<{link app=b2c ctl=site_cart act=index}>"  class="cart-container">
    <span class="inlineblock CartIco"><{t app="b2c"}>购物车<{/t}></span>
  [<span id="Cart_<{$widgets_id}>" class="cart-number">0</span>]
  </a>
  <{/if}>
</span>
<script>
/*
*foobar update:2009-9-8 13:46:55
*@author litie[aita]shopex.cn
*-----------------*/
window.addEvent('domready',function(){
       var barId ="<{$widgets_id}>";
       var bar = $('foobar_'+barId);

       var barOptions = {
           MID:Cookie.read('S[MEMBER]')?Cookie.read('S[MEMBER]'):'',
           coin:<{$data.cur|default:'null'}>,
           curCoin:Cookie.read('S[CUR]')?Cookie.read('S[CUR]'):'<{$data.def_cur.cur_code}>',
           cartViewURl:'<{link app=b2c ctl="site_cart" act="view"}>',
           stick:<{if $setting.stick}>true<{else}>false<{/if}>
       };

       /**/if(barOptions.MID){
          //$('loginBar_'+barId).hide();
          $('memberBar_'+barId).show();
       }else{
          //$('loginBar_'+barId).setStyle('visibility','visible');
       }//*/

       if(coinBar=$('Cur_sel_'+barId)){

           var coinMenu = new Element('div',{'class':'coinmenu fmenu','styles':{'display':'none'}}).inject(document.body);
    /**/
           barOptions.coin.each(function(item){

                if(item['cur_code']==barOptions['curCoin']){
                   coinBar.getElement('strong').set('text',[item.cur_sign,item.cur_name].join(''));
                }
                coinMenu.adopt(new Element('div',{'class':'item',text:[item.cur_sign,item.cur_name].join(''),events:{
                      click:function(){
                          Cookie.write('S[CUR]',item.cur_code,{path:"<{$data.base_url}>"});
                          if(item['cur_code'] != barOptions['curCoin']) {
                            new Request.JSON({
                                url:'<{link app=b2c ctl=site_cart act=getCartTotalPrice}>',
                                data:'currency='+item['cur_code'],
                                onSuccess:function(rs){
                                    Cookie.write('S[CART_TOTAL_PRICE]',rs,{path:"/"});
                                },
                                onComplete:function(){
                                    window.location.href=window.location.href;
                                }
                            }).send();
                          }
                          else{
                            window.location.href=window.location.href;
                          }
                      }

                }}));
           });
           //*/
            coinBar.addEvents({
                'mouseenter':function(){
                   coinMenu.setStyles({
                      top:coinBar.getPosition().y+coinBar.getSize().y,
                      left:coinBar.getPosition().x,
                      display:'block',
                      visibility:'visible'
                   });
                }
            });
            new DropMenu(coinBar,{menu:coinMenu});


       }

       if(cartCountBar = $('Cart_'+barId)){
        <{if $setting.cart_show_type==1}>
            cartCountBar.set('text',Cookie.read('S[CART_NUMBER]')?Cookie.read('S[CART_NUMBER]'):0);
        <{else}>
            cartCountBar.set('text',Cookie.read('S[CART_COUNT]')?Cookie.read('S[CART_COUNT]'):0);
        <{/if}>
            var cartViewMenu =  new Element('div',{'class':'cartviewmenu fmenu','styles':{'display':'none'}}).inject(document.body);
            cartCountBar.addEvents({
                 'mouseenter':function(){
                   cartViewMenu.setStyles({
                      top:bar.getPosition().y+bar.getSize().y,
                      left:bar.getPosition().x,
                      width:bar.getSize().x,
                      display:'block',
                      visibility:'visible'
                   }).set('html','<div class="note"><{t app="b2c"}>正在加载购物车信息...<{/t}></div>');
                    this.retrieve('request',{cancel:function(){}}).cancel();
                    this.store('request',new Request.HTML({url:barOptions.cartViewURl,
                        onComplete:function(){
                            cartViewMenu.getElements('.delcart').addEvent('click',function(e){
                                var itm = this.getParent('.minicart-single');
                                var itm_id = itm.get('chlid_id').substr(4).toInt();
                                var act = itm.get('urlremove');
                                itm.dispose();
                                new Request({
                                    url: act,
                                    data: cartViewMenu,
                                    onComplete: function(re){
                                        if(!re)return;
                                        MessageBox.success('删除成功');
                                        <{if $setting.cart_show_type==1}>
                                            cartCountBar.set('text',Cookie.read('S[CART_NUMBER]')?Cookie.read('S[CART_NUMBER]'):0);
                                        <{else}>
                                            cartCountBar.set('text',Cookie.read('S[CART_COUNT]')?Cookie.read('S[CART_COUNT]'):0);
                                        <{/if}>
                                    }
                                }).send();

                            });
                            cartViewMenu.getElement('.nodisplay').destroy();
                        },
                    update:cartViewMenu}).get());
                }
            });

            new DropMenu(cartCountBar,{menu:cartViewMenu});

       }

});
    var e = Cookie.read('UNAME')?Cookie.read('UNAME'):'';
    /*
    new Request({
        url:'<{link app=b2c ctl=site_passport act=getuname}>',
        method:'post',
        onComplete:function(e){
        */
            if(e){
                $("uname_<{$widgets_id}>").innerHTML = e;
                $("memberBar_<{$widgets_id}>").setStyle('display','inline');
                if($("loginBar_<{$widgets_id}>"))
                $("loginBar_<{$widgets_id}>").setStyle('display','none');
            }
            else{
                $("loginBar_<{$widgets_id}>").setStyle('display','inline');
                if($("memberBar_<{$widgets_id}>"))
                $("memberBar_<{$widgets_id}>").setStyle('display','none');
            }
            /*
        },
        data:''
        }).send();*/
</script>
 <{if $data.open_id_open=='true' && !$env.cookie.MEMBER}>
<style id='thridpartystyle'>
.trustlogin { background:url(<{$data.res_url}>/icons/thridparty1.gif) no-repeat left; padding-left:18px; height:20px; line-height:20px; }
#accountlogin{display:none;cursor:pointer;padding:5px;width:170px;z-index:100; position:absolute; border:2px solid #BADBF2; background:#fff; }
#accountlogin span{display:block;width:80px;height:27px;float:left;_display:inline;margin:2px;_margin:2px 1px 2px 2px;}
</style>

<script>
(function(){
    var loginBtn=$('loginBar_<{$widgets_id}>').getElements('.trust__login'),timer;
    $$(loginBtn,$('accountlogin')).addEvents({'mouseenter':function(){
            if(timer)clearTimeout(timer);
            $('accountlogin').setStyles({'display':'block','top':'20','left':'10'});
        },'mouseleave':function(){
            timer=function(){$('accountlogin').setStyle('display','none')}.delay(200);
        }
    });
    $('accountlogin').addEvent('click',function(e){loginBtn.fireEvent('click');})
})();
</script>
<{/if}>
